package org.white.word2pdf.handler;

import java.util.Optional;
import javax.servlet.http.HttpServletRequest;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.method.HandlerMethod;
import org.white.word2pdf.ErrorException;

@ControllerAdvice
public class CommonExceptionHandler {
    public CommonExceptionHandler() {
    }

    @ExceptionHandler({ErrorException.class})
    public ResponseEntity<ExceptionResponse> process(HttpServletRequest request, HandlerMethod method, ErrorException exception) {
        ExceptionResponse er = new ExceptionResponse(exception.getMsg());
        return new ResponseEntity(er, HttpStatus.OK);
    }
}
